package org.example.tlias.services.impl;

import org.apache.ibatis.annotations.Mapper;
import org.example.tlias.mapper.EmpMapper;
import org.example.tlias.pojo.JobOption;
import org.example.tlias.services.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import static java.util.stream.Collectors.toList;

@Service
public class ReportServiceImpl implements ReportService{

    @Autowired
    private EmpMapper empMapper;

    @Override
    public JobOption getEmpJobData() {
        List<Map<String, Object>> lists = empMapper.countEmpJobData();
        JobOption jobOption = new JobOption();
        List<String> ops = lists.stream().
                map(dataMap -> (String) dataMap.get("ops")).toList();
        List<Object> nums = lists.stream()
                .map(dataMap ->  dataMap.get("num"))
                .toList();

        return new JobOption(ops,nums);
    }

    @Override
    public List<Map> getEmpGenderData() {

        return empMapper.countEmpGenderData();
    }
}
